/* Class: UWA.Environments.Frame

_Copyright 2006-2007 Netvibes. All rights reserved._

*/

Object.extend( UWA.Environment.prototype, {
  
  /**
   * Companion to registerModule()
   *
   * @private
   * @param {module}
   * @return void
   */  
  onRegisterModule: function(module) {
    
    this.html['body'] = $('moduleContent');
    this.module.elements['body'] = UWA.$element(this.html['body']);
    
    this.module.body = this.module.elements['body']; // shortcut
    
    this.setDelayed('launchModule', this.launchModule, 100)
    
  },

  /**
   * Return the variable value from the Environnement
   *
   * @public
   * @param {name}
   * @return mix
   */   
  getData: function(name) {
    if (this.data[name]) return this.data[name];
    //else if (window.Cookie) return Cookie.get(name);
    return undefined;
  },
  
  /**
   * Set the variable in the Environnement
   *
   * @public
   * @param {name}
   * @param {value}
   * @return void
   */   
  setData: function(name, value) {
    this.data[name] = value;
    // if (window.Cookie) Cookie.set(name, value);
  },
  
  /* to document */
  handleLinks: function() {
    var links = this.module.body.getElementsByTagName('a');
    for (var i = 0, lnk; lnk = links[i]; i++) {
      lnk.target = '_blank'; // problem with javascript void(0) links
    }
  },
  
  /* to document */
  onUpdateBody: function() {
    this.setDelayed('handleLinks', this.handleLinks, 100);
  }
  
} );

function _(s) {
  return s;
}